package com.whmskj.xjlhsc.mobie.ProductionManagement.controller;

import cn.dev33.satoken.annotation.SaIgnore;
import com.whmskj.xjlhsc.controller.vo.Result;
import com.whmskj.xjlhsc.mobie.ProductionManagement.pojo.dto.AddDustFilterPackingDTO;
import com.whmskj.xjlhsc.mobie.ProductionManagement.pojo.dto.GetMyselfDTO;
import com.whmskj.xjlhsc.mobie.ProductionManagement.pojo.dto.ListDustFilterPackingDTO;
import com.whmskj.xjlhsc.mobie.ProductionManagement.pojo.entity.BackToYourFeetAndWeigh;
import com.whmskj.xjlhsc.mobie.ProductionManagement.pojo.vo.PackingTypeVO;
import com.whmskj.xjlhsc.mobie.ProductionManagement.service.imp.DustFilterPackingServiceImpl;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @author jiaruchun
 * @date 2025-08-28 17:23
 */
@SaIgnore
@RestController
@Api(tags = " 滤尘打包接口")
@RequestMapping("/mobile/ProductionManagement/DustFilterPacking")
public class DustFilterPackingController {
    @Autowired
    private DustFilterPackingServiceImpl dustFilterPackingService;

    //查询班次信息
    @GetMapping("/shift")
    /*TODO 现在班次表没数据，先返回早班,写死*/
    public Result getShift(@RequestParam("time") @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate time) {
        return Result.success(dustFilterPackingService.getShift(time));
    }

    //查看当前用户某天打包信息
    @PostMapping("/myself")
    public Result getMyself(@RequestBody GetMyselfDTO getMyselfDTO){
        return Result.success(dustFilterPackingService.getMyself(getMyselfDTO));
    }

    //新增
    @PostMapping
    public Result addDustFilterPacking(@RequestBody AddDustFilterPackingDTO addDustFilterPackingDTO) {
        dustFilterPackingService.addDustFilterPacking(addDustFilterPackingDTO);
        return Result.success();
    }

    //删除
    @DeleteMapping("/delete/{id}")
    public Result deleteDustFilterPacking(@PathVariable("id") Integer id) {
        dustFilterPackingService.deleteDustFilterPacking(id);
        return Result.success();
    }

    //修改
    @PutMapping("/update")
    public Result updateDustFilterPacking(@RequestBody List<BackToYourFeetAndWeigh> dustFilterPackingList) {
        dustFilterPackingService.updateDustFilterPacking(dustFilterPackingList);
        return Result.success();
    }
    //列表查询
    @PostMapping("/list")
    public Result listDustFilterPacking(@RequestBody ListDustFilterPackingDTO listDustFilterPackingDTO) {
        return Result.success(dustFilterPackingService.listDustFilterPacking(listDustFilterPackingDTO));
    }

    @GetMapping
    public Result getTypeList() {
        ArrayList<PackingTypeVO> packingTypeVOS = new ArrayList<>() {{
            add(new PackingTypeVO("1清落"));
            add(new PackingTypeVO("2梳落"));
            add(new PackingTypeVO("3精落"));
            add(new PackingTypeVO("4白花"));
            add(new PackingTypeVO("5黑吸风"));
            add(new PackingTypeVO("6回丝"));
            add(new PackingTypeVO("7三丝花"));
            add(new PackingTypeVO("8粗纱头"));
            add(new PackingTypeVO("9白吸风"));
            add(new PackingTypeVO("10扫地花"));
            add(new PackingTypeVO("11滤尘土"));
            add(new PackingTypeVO("12回条"));
            add(new PackingTypeVO("13塑料包布"));
            add(new PackingTypeVO("14尾纱机白花"));
        }};
        return Result.success(packingTypeVOS);
    }
}
